package cn.iocoder.yudao.module.biz.dal.mysql.contract;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.ContractArchiveDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.biz.controller.admin.contract.vo.*;

import java.util.List;

/**
 * 合同档案 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface ContractArchiveMapper extends BaseMapperX<ContractArchiveDO> {

    default PageResult<ContractArchiveDO> selectPage(ContractArchivePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ContractArchiveDO>()
                .likeIfPresent(ContractArchiveDO::getContractName, reqVO.getContractName())
                .eqIfPresent(ContractArchiveDO::getContractCode, reqVO.getContractCode())
                .eqIfPresent(ContractArchiveDO::getCustomerId, reqVO.getCustomerId())
                .likeIfPresent(ContractArchiveDO::getCustomerName, reqVO.getCustomerName())
                .betweenIfPresent(ContractArchiveDO::getSignTime, reqVO.getSignTime())
                .eqIfPresent(ContractArchiveDO::getPowerAccount, reqVO.getPowerAccount())
                .eqIfPresent(ContractArchiveDO::getProjectCode, reqVO.getProjectCode())
                .likeIfPresent(ContractArchiveDO::getCustomerDirectorName, reqVO.getCustomerDirectorName())
                .eqIfPresent(ContractArchiveDO::getContactNumber, reqVO.getContactNumber())
                .likeIfPresent(ContractArchiveDO::getCompanyDirectorName, reqVO.getCompanyDirectorName())
                .eqIfPresent(ContractArchiveDO::getManageUnitId, reqVO.getManageUnitId())
                .likeIfPresent(ContractArchiveDO::getManageUnitName, reqVO.getManageUnitName())
                .eqIfPresent(ContractArchiveDO::getCostomerManager, reqVO.getCostomerManager())
                .eqIfPresent(ContractArchiveDO::getPowerLocation, reqVO.getPowerLocation())
                .eqIfPresent(ContractArchiveDO::getPowerAddress, reqVO.getPowerAddress())
                .eqIfPresent(ContractArchiveDO::getPowerArea, reqVO.getPowerArea())
                .eqIfPresent(ContractArchiveDO::getServiceContent, reqVO.getServiceContent())
                .eqIfPresent(ContractArchiveDO::getSupplement, reqVO.getSupplement())
                .eqIfPresent(ContractArchiveDO::getTransformerAmount, reqVO.getTransformerAmount())
                .eqIfPresent(ContractArchiveDO::getTotalVolume, reqVO.getTotalVolume())
                .eqIfPresent(ContractArchiveDO::getMeasureAmount, reqVO.getMeasureAmount())
                .betweenIfPresent(ContractArchiveDO::getContractStartTime, reqVO.getContractStartTime())
                .betweenIfPresent(ContractArchiveDO::getContractEndTime, reqVO.getContractEndTime())
                .eqIfPresent(ContractArchiveDO::getContractMonthNumber, reqVO.getContractMonthNumber())
                .eqIfPresent(ContractArchiveDO::getContractMonthText, reqVO.getContractMonthText())
                .eqIfPresent(ContractArchiveDO::getFeePerMontNumber, reqVO.getFeePerMontNumber())
                .eqIfPresent(ContractArchiveDO::getFeePerMontText, reqVO.getFeePerMontText())
                .eqIfPresent(ContractArchiveDO::getFactFeePerMonthNumber, reqVO.getFactFeePerMonthNumber())
                .eqIfPresent(ContractArchiveDO::getFactFeePerMonthText, reqVO.getFactFeePerMonthText())
                .eqIfPresent(ContractArchiveDO::getContractPriceNumber, reqVO.getContractPriceNumber())
                .eqIfPresent(ContractArchiveDO::getContractPriceText, reqVO.getContractPriceText())
                .eqIfPresent(ContractArchiveDO::getFirstPay, reqVO.getFirstPay())
                .betweenIfPresent(ContractArchiveDO::getFirstPayDate, reqVO.getFirstPayDate())
                .eqIfPresent(ContractArchiveDO::getInstalmentCount, reqVO.getInstalmentCount())
                .eqIfPresent(ContractArchiveDO::getReceiveInterval, reqVO.getReceiveInterval())
                .eqIfPresent(ContractArchiveDO::getIntervalPay, reqVO.getIntervalPay())
                .eqIfPresent(ContractArchiveDO::getServiceUnitId, reqVO.getServiceUnitId())
                .likeIfPresent(ContractArchiveDO::getServiceUnitName, reqVO.getServiceUnitName())
                .likeIfPresent(ContractArchiveDO::getServiceManagerName, reqVO.getServiceManagerName())
                .eqIfPresent(ContractArchiveDO::getIntroducer, reqVO.getIntroducer())
                .eqIfPresent(ContractArchiveDO::getIntroduceChannel, reqVO.getIntroduceChannel())
                .eqIfPresent(ContractArchiveDO::getRemark, reqVO.getRemark())
                .eqIfPresent(ContractArchiveDO::getAttachmentUrl, reqVO.getAttachmentUrl())
                .betweenIfPresent(ContractArchiveDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ContractArchiveDO::getOwnerUserId, reqVO.getOwnerUserId())
                .eqIfPresent(ContractArchiveDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ContractArchiveDO::getIsTest, reqVO.getIsTest())
                .eqIfPresent(ContractArchiveDO::getContractType, reqVO.getContractType())
                .eqIfPresent(ContractArchiveDO::getContractSubmitTime, reqVO.getContractSubmitTime())
                .eqIfPresent(ContractArchiveDO::getContractCompleteTime, reqVO.getContractCompleteTime())
                .orderByDesc(ContractArchiveDO::getId));
    }

    ContractArchiveDO getContractArchiveDetail(Long id);

    List<ContractArchiveDO> getExpiredContractArchiveList();

    void changeStatusToRenew(Long id);

}